home *** CD-ROM | disk | FTP | other *** search
/ Personal Computer World 2007 November / PCWNOV07.iso / Software / Freeware / NSIS 2.29 / nsis-2.29-setup.exe / Examples / StrFunc.nsi < prev    next >
Encoding:
Text File  |  2005-09-16  |  22.2 KB  |  635 lines

  1. Name "NSIS StrFunc Example"
  2. OutFile "StrFunc.exe"
  3. ShowInstDetails show
  4. ShowUninstDetails show
  5. XPStyle on
  6.  
  7. !include "StrFunc.nsh"
  8.  
  9. # Declare used functions
  10. ${StrCase}
  11. ${StrClb}
  12. ${StrIOToNSIS}
  13. ${StrLoc}
  14. ${StrNSISToIO}
  15. ${StrRep}
  16. ${StrStr}
  17. ${StrStrAdv}
  18. ${StrTok}
  19. ${StrTrimNewLines}
  20. ${StrSort}
  21.  
  22. ${UnStrCase}
  23. ${UnStrClb}
  24. ${UnStrIOToNSIS}
  25. ${UnStrLoc}
  26. ${UnStrNSISToIO}
  27. ${UnStrRep}
  28. ${UnStrStr}
  29. ${UnStrStrAdv}
  30. ${UnStrTok}
  31. ${UnStrTrimNewLines}
  32. ${UnStrSort}
  33.  
  34. !macro StackVerificationStart
  35.   StrCpy $0 S0
  36.   StrCpy $1 S1
  37.   StrCpy $2 S2
  38.   StrCpy $3 S3
  39.   StrCpy $4 S4
  40.   StrCpy $5 S5
  41.   StrCpy $6 S6
  42.   StrCpy $7 S7
  43.   StrCpy $8 S8
  44.   StrCpy $9 S9
  45.   StrCpy $R0 SR0
  46.   StrCpy $R1 SR1
  47.   StrCpy $R2 SR2
  48.   StrCpy $R3 SR3
  49.   StrCpy $R4 SR4
  50.   StrCpy $R5 SR5
  51.   StrCpy $R6 SR6
  52.   StrCpy $R7 SR7
  53.   StrCpy $R8 SR8
  54.   StrCpy $R9 SR9
  55. !macroend
  56.  
  57. !macro StackVerificationEnd
  58.   ClearErrors
  59.   ${If} $1 != "S1"
  60.   ${OrIf} $2 != "S2"
  61.   ${OrIf} $3 != "S3"
  62.   ${OrIf} $4 != "S4"
  63.   ${OrIf} $5 != "S5"
  64.   ${OrIf} $6 != "S6"
  65.   ${OrIf} $7 != "S7"
  66.   ${OrIf} $8 != "S8"
  67.   ${OrIf} $9 != "S9"
  68.   ${OrIf} $R0 != "SR0"
  69.   ${OrIf} $R1 != "SR1"
  70.   ${OrIf} $R2 != "SR2"
  71.   ${OrIf} $R3 != "SR3"
  72.   ${OrIf} $R4 != "SR4"
  73.   ${OrIf} $R5 != "SR5"
  74.   ${OrIf} $R6 != "SR6"
  75.   ${OrIf} $R7 != "SR7"
  76.   ${OrIf} $R8 != "SR8"
  77.   ${OrIf} $R9 != "SR9"
  78.     SetErrors
  79.   ${EndIf}
  80. !macroend
  81.  
  82. Section
  83.  
  84.   # Test case conversion
  85.   !insertmacro StackVerificationStart
  86.   ${StrCase} $0 "This is just an example. A very simple one." ""
  87.   StrCmp $0 "This is just an example. A very simple one." 0 strcaseerror
  88.   ${StrCase} $0 "THIS IS JUST AN EXAMPLE. A VERY SIMPLE ONE." "S"
  89.   StrCmp $0 "This is just an example. A very simple one." 0 strcaseerror
  90.   ${StrCase} $0 "This is just an example. A very simple one." "L"
  91.   StrCmp $0 "this is just an example. a very simple one." 0 strcaseerror
  92.   ${StrCase} $0 "This is just an example. A very simple one." "U"
  93.   StrCmp $0 "THIS IS JUST AN EXAMPLE. A VERY SIMPLE ONE." 0 strcaseerror
  94.   ${StrCase} $0 "This is just an example. A very simple one." "T"
  95.   StrCmp $0 "This Is Just An Example. A Very Simple One." 0 strcaseerror
  96.   ${StrCase} $0 "This is just an example. A very simple one." "<>"
  97.   StrCmp $0 "tHIS IS JUST AN EXAMPLE. a VERY SIMPLE ONE." 0 strcaseerror
  98.   ${StrCase} $0 "123456789!@#%^&*()-_=+[]{};:,./<>?" "S"
  99.   StrCmp $0 "123456789!@#%^&*()-_=+[]{};:,./<>?" 0 strcaseerror
  100.   ${StrCase} $0 "123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ!@#%^&*()abcdefghijklmnopqrstuvwxyz-_=+[]{};:,./<>?" "<>"
  101.   StrCmp $0 "123456789abcdefghijklmnopqrstuvwxyz!@#%^&*()ABCDEFGHIJKLMNOPQRSTUVWXYZ-_=+[]{};:,./<>?" 0 strcaseerror
  102.   ${StrCase} $0 "what about taking a shower tomorrow? it's late to do so now! try to sleep now. Good Night!" "S"
  103.   StrCmp $0 "What about taking a shower tomorrow? It's late to do so now! Try to sleep now. Good night!" 0 strcaseerror
  104.   !insertmacro StackVerificationEnd
  105.   IfErrors strcaseerror
  106.  
  107.   DetailPrint "PASSED StrCase test"
  108.   Goto +2
  109. strcaseerror:
  110.   DetailPrint "FAILED StrCase test"
  111.  
  112.   # Test clipboard function
  113.   !insertmacro StackVerificationStart
  114.   ${StrClb} $0 "StrFunc clipboard test" ">"
  115.   StrCmp $0 "" 0 strclberror
  116.   ${StrClb} $0 "StrFunc clipboard test #2" "<>"
  117.   StrCmp $0 "StrFunc clipboard test" 0 strclberror
  118.   ${StrClb} $0 "" "<"
  119.   StrCmp $0 "StrFunc clipboard test #2" 0 strclberror
  120.   ${StrClb} $0 "" ""
  121.   StrCmp $0 "" 0 strclberror
  122.   !insertmacro StackVerificationEnd
  123.   IfErrors strclberror
  124.  
  125.   DetailPrint "PASSED StrClb test"
  126.   Goto +2
  127. strclberror:
  128.   DetailPrint "FAILED StrClb test"
  129.  
  130.   # Test IO functions
  131.   !insertmacro StackVerificationStart
  132.   !macro testio str
  133.   ${StrNSISToIO} $0 "${str}"
  134.   ${StrIOToNSIS} $0 $0
  135.   StrCmp $0 "${str}" 0 ioerror
  136.   !macroend
  137.   !insertmacro testio "$\rtest$\n"
  138.   !insertmacro testio "test$\n"
  139.   !insertmacro testio "$\rtest"
  140.   !insertmacro testio "test"
  141.   !insertmacro testio "$\r\$\t$\n"
  142.   !insertmacro testio "$\r \ $\t $\n $$"
  143.   !insertmacro testio ""
  144.   !insertmacro testio " "
  145.   !insertmacro StackVerificationEnd
  146.   IfErrors ioerror
  147.  
  148.   DetailPrint "PASSED StrNSISToIO/StrIOToNSIS test"
  149.   Goto +2
  150. ioerror:
  151.   DetailPrint "FAILED StrNSISToIO/StrIOToNSIS test"
  152.  
  153.   # Test string search functions
  154.   !insertmacro StackVerificationStart
  155.   ${StrLoc} $0 "This is just an example" "just" "<"
  156.   StrCmp $0 "11" 0 strlocerror
  157.   ${StrLoc} $0 a abc <
  158.   StrCmp $0 "" 0 strlocerror
  159.   ${StrLoc} $0 a abc >
  160.   StrCmp $0 "" 0 strlocerror
  161.   ${StrLoc} $0 abc a >
  162.   StrCmp $0 "0" 0 strlocerror
  163.   ${StrLoc} $0 abc b >
  164.   StrCmp $0 "1" 0 strlocerror
  165.   ${StrLoc} $0 abc c >
  166.   StrCmp $0 "2" 0 strlocerror
  167.   ${StrLoc} $0 abc a <
  168.   StrCmp $0 "2" 0 strlocerror
  169.   ${StrLoc} $0 abc b <
  170.   StrCmp $0 "1" 0 strlocerror
  171.   ${StrLoc} $0 abc c <
  172.   StrCmp $0 "0" 0 strlocerror
  173.   ${StrLoc} $0 abc d <
  174.   StrCmp $0 "" 0 strlocerror
  175.   !insertmacro StackVerificationEnd
  176.   IfErrors strlocerror
  177.   
  178.   DetailPrint "PASSED StrLoc test"
  179.   Goto +2
  180. strlocerror:
  181.   DetailPrint "FAILED StrLoc test"
  182.  
  183.   # Test string replacement
  184.   !insertmacro StackVerificationStart
  185.   ${StrRep} $0 "This is just an example" "an" "one"
  186.   StrCmp $0 "This is just one example" 0 strreperror
  187.   ${StrRep} $0 "test... test... 1 2 3..." "test" "testing"
  188.   StrCmp $0 "testing... testing... 1 2 3..." 0 strreperror
  189.   ${StrRep} $0 "" "test" "testing"
  190.   StrCmp $0 "" 0 strreperror
  191.   ${StrRep} $0 "test" "test" "testing"
  192.   StrCmp $0 "testing" 0 strreperror
  193.   ${StrRep} $0 "test" "test" ""
  194.   StrCmp $0 "" 0 strreperror
  195.   ${StrRep} $0 "test" "" "abc"
  196.   StrCmp $0 "test" 0 strreperror
  197.   ${StrRep} $0 "test" "" ""
  198.   StrCmp $0 "test" 0 strreperror
  199.   !insertmacro StackVerificationEnd
  200.   IfErrors strreperror
  201.   
  202.   DetailPrint "PASSED StrRep test"
  203.   Goto +2
  204. strreperror:
  205.   DetailPrint "FAILED StrRep test"
  206.  
  207.   # Test sorting
  208.   !insertmacro StackVerificationStart
  209.   ${StrSort} $0 "This is just an example" "" " just" "ple" "0" "0" "0"
  210.   StrCmp $0 "This is an exam" 0 strsorterror
  211.   ${StrSort} $0 "This is just an example" " " "j" " " "0" "" "0"
  212.   StrCmp $0 "just" 0 strsorterror
  213.   ${StrSort} $0 "This is just an example" "" "j" "" "0" "1" "0"
  214.   StrCmp $0 "This is just an example" 0 strsorterror
  215.   ${StrSort} $0 "This is just an example" " " "us" "" "0" "1" "0"
  216.   StrCmp $0 "just an example" 0 strsorterror
  217.   ${StrSort} $0 "This is just an example" "" "u" " " "0" "1" "0"
  218.   StrCmp $0 "This is just" 0 strsorterror
  219.   ${StrSort} $0 "This is just an example" " " "just" " " "0" "1" "0"
  220.   StrCmp $0 "just" 0 strsorterror
  221.   ${StrSort} $0 "This is just an example" " " "t" " " "0" "1" "0"
  222.   StrCmp $0 "This" 0 strsorterror
  223.   ${StrSort} $0 "This is just an example" " " "le" " " "0" "1" "0"
  224.   StrCmp $0 "example" 0 strsorterror
  225.   ${StrSort} $0 "This is just an example" " " "le" " " "1" "0" "0"
  226.   StrCmp $0 " examp" 0 strsorterror
  227.   ${StrSort} $0 "an error has occurred" " " "e" " " "0" "1" "0"
  228.   StrCmp $0 "error" 0 strsorterror
  229.   ${StrSort} $0 "" " " "something" " " "0" "1" "0"
  230.   StrCmp $0 "" 0 strsorterror
  231.   ${StrSort} $0 "This is just an example" " " "j" " " "" "" ""
  232.   StrCmp $0 " just " 0 strsorterror
  233.   ${StrSort} $0 "This is just an example" " " "j" " " "1" "0" "1"
  234.   StrCmp $0 " ust " 0 strsorterror
  235.   ${StrSort} $0 "This is just an example" "" "j" "" "0" "0" "1"
  236.   StrCmp $0 "This is ust an example" 0 strsorterror
  237.   ${StrSort} $0 "This is just an example" " " "us" "" "1" "0" "0"
  238.   StrCmp $0 " jt an example" 0 strsorterror
  239.   ${StrSort} $0 "This is just an example" "" "u" " " "0" "0" "1"
  240.   StrCmp $0 "This is jst " 0 strsorterror
  241.   ${StrSort} $0 "This is just an example" " " "just" " " "1" "0" "1"
  242.   StrCmp $0 "  " 0 strsorterror
  243.   ${StrSort} $0 "an error has occurred" " " "e" "h" "1" "0" "0"
  244.   StrCmp $0 " rror " 0 strsorterror
  245.   ${StrSort} $0 "" " " "something" " " "1" "0" "1"
  246.   StrCmp $0 "" 0 strsorterror
  247.   !insertmacro StackVerificationEnd
  248.   IfErrors strsorterror
  249.   
  250.   DetailPrint "PASSED StrSort test"
  251.   Goto +2
  252. strsorterror:
  253.   DetailPrint "FAILED StrSort test"
  254.  
  255.   !insertmacro StackVerificationStart
  256.   ${StrStr} $0 "abcefghijklmnopqrstuvwxyz" "g"
  257.   StrCmp $0 "ghijklmnopqrstuvwxyz" 0 strstrerror
  258.   ${StrStr} $0 "abcefghijklmnopqrstuvwxyz" "ga"
  259.   StrCmp $0 "" 0 strstrerror
  260.   ${StrStr} $0 "abcefghijklmnopqrstuvwxyz" ""
  261.   StrCmp $0 "abcefghijklmnopqrstuvwxyz" 0 strstrerror
  262.   ${StrStr} $0 "a" "abcefghijklmnopqrstuvwxyz"
  263.   StrCmp $0 "" 0 strstrerror
  264.   !insertmacro StackVerificationEnd
  265.   IfErrors strstrerror
  266.   
  267.   DetailPrint "PASSED StrStr test"
  268.   Goto +2
  269. strstrerror:
  270.   DetailPrint "FAILED StrStr test"
  271.  
  272.   !insertmacro StackVerificationStart
  273.   ${StrStrAdv} $0 "abcabcabc" "a" ">" ">" "1" "0" "0"
  274.   StrCmp $0 "abcabcabc" 0 strstradverror
  275.   ${StrStrAdv} $0 "abcabcabc" "a" ">" ">" "1" "1" "0"
  276.   StrCmp $0 "abcabc" 0 strstradverror
  277.   ${StrStrAdv} $0 "abcabcabc" "a" ">" ">" "1" "2" "0"
  278.   StrCmp $0 "abc" 0 strstradverror
  279.   ${StrStrAdv} $0 "abcabcabc" "a" ">" ">" "1" "3" "0"
  280.   StrCmp $0 "" 0 strstradverror
  281.   ${StrStrAdv} $0 "abcabcabc" "abc" ">" "<" "1" "1" "0"
  282.   StrCmp $0 "abcabc" 0 strstradverror
  283.   ${StrStrAdv} $0 "abcabcabc" "abc" ">" "<" "0" "1" "0"
  284.   StrCmp $0 "abc" 0 strstradverror
  285.   ${StrStrAdv} $0 "abcabcabc" "abc" "<" "<" "1" "0" "0"
  286.   StrCmp $0 "abcabcabc" 0 strstradverror
  287.   ${StrStrAdv} $0 "abcabcabc" "abc" "<" "<" "0" "0" "0"
  288.   StrCmp $0 "abcabc" 0 strstradverror
  289.   ${StrStrAdv} $0 "abcabcabc" "abc" "<" ">" "0" "0" "0"
  290.   StrCmp $0 "" 0 strstradverror
  291.   ${StrStrAdv} $0 "abcabcabc" "abc" "<" ">" "0" "1" "0"
  292.   StrCmp $0 "abc" 0 strstradverror
  293.   ${StrStrAdv} $0 "ABCabcabc" "a" ">" ">" "1" "0" "1"
  294.   StrCmp $0 "abcabc" 0 strstradverror
  295.   ${StrStrAdv} $0 "ABCabcabc" "a" ">" ">" "1" "1" "1"
  296.   StrCmp $0 "abc" 0 strstradverror
  297.   ${StrStrAdv} $0 "ABCabcabc" "a" ">" ">" "1" "2" "1"
  298.   StrCmp $0 "" 0 strstradverror
  299.   ${StrStrAdv} $0 "ABCabcabc" "a" ">" ">" "1" "3" "1"
  300.   StrCmp $0 "" 0 strstradverror
  301.   ${StrStrAdv} $0 "ABCabcabc" "abc" ">" "<" "1" "1" "1"
  302.   StrCmp $0 "ABCabcabc" 0 strstradverror
  303.   ${StrStrAdv} $0 "ABCabcabc" "abc" ">" "<" "0" "1" "1"
  304.   StrCmp $0 "ABCabc" 0 strstradverror
  305.   ${StrStrAdv} $0 "ABCabcabc" "abc" "<" "<" "1" "0" "1"
  306.   StrCmp $0 "ABCabcabc" 0 strstradverror
  307.   ${StrStrAdv} $0 "ABCabcabc" "abc" "<" "<" "0" "0" "1"
  308.   StrCmp $0 "ABCabc" 0 strstradverror
  309.   ${StrStrAdv} $0 "ABCabcabc" "abc" "<" ">" "0" "0" "1"
  310.   StrCmp $0 "" 0 strstradverror
  311.   ${StrStrAdv} $0 "ABCabcabc" "abc" "<" ">" "0" "1" "1"
  312.   StrCmp $0 "abc" 0 strstradverror
  313.   !insertmacro StackVerificationEnd
  314.   IfErrors strstradverror
  315.   
  316.   DetailPrint "PASSED StrStrAdv test"
  317.   Goto +2
  318. strstradverror:
  319.   DetailPrint "FAILED StrStrAdv test"
  320.  
  321.   # Test tokenizer
  322.   !insertmacro StackVerificationStart
  323.   ${StrTok} $0 "This is, or is not, just an example" " ," "4" "1"
  324.   StrCmp $0 "not" 0 strtokerror
  325.   ${StrTok} $0 "This is, or is not, just an example" " ," "4" "0"
  326.   StrCmp $0 "is" 0 strtokerror
  327.   ${StrTok} $0 "This is, or is not, just an example" " ," "152" "0"
  328.   StrCmp $0 "" 0 strtokerror
  329.   ${StrTok} $0 "This is, or is not, just an example" " ," "" "0"
  330.   StrCmp $0 "example" 0 strtokerror
  331.   ${StrTok} $0 "This is, or is not, just an example" " ," "L" "0"
  332.   StrCmp $0 "example" 0 strtokerror
  333.   ${StrTok} $0 "This is, or is not, just an example" " ," "0" "0"
  334.   StrCmp $0 "This" 0 strtokerror
  335.   !insertmacro StackVerificationEnd
  336.   IfErrors strtokerror
  337.   
  338.   DetailPrint "PASSED StrTok test"
  339.   Goto +2
  340. strtokerror:
  341.   DetailPrint "FAILED StrTok test"
  342.  
  343.   # Test trim new lines
  344.   !insertmacro StackVerificationStart
  345.   ${StrTrimNewLines} $0 "$\r$\ntest$\r$\ntest$\r$\n"
  346.   StrCmp $0 "$\r$\ntest$\r$\ntest" 0 strtrimnewlineserror
  347.   !insertmacro StackVerificationEnd
  348.   IfErrors strtrimnewlineserror
  349.  
  350.   DetailPrint "PASSED StrTrimNewLines test"
  351.   Goto +2
  352. strtrimnewlineserror:
  353.   DetailPrint "FAILED StrTrimNewLines test"
  354.  
  355.   WriteUninstaller $EXEDIR\UnStrFunc.exe
  356.   
  357.   Exec $EXEDIR\UnStrFunc.exe
  358.  
  359. SectionEnd
  360.  
  361. Section Uninstall
  362.  
  363.   # Test case conversion
  364.   !insertmacro StackVerificationStart
  365.   ${UnStrCase} $0 "This is just an example. A very simple one." ""
  366.   StrCmp $0 "This is just an example. A very simple one." 0 strcaseerror
  367.   ${UnStrCase} $0 "THIS IS JUST AN EXAMPLE. A VERY SIMPLE ONE." "S"
  368.   StrCmp $0 "This is just an example. A very simple one." 0 strcaseerror
  369.   ${UnStrCase} $0 "This is just an example. A very simple one." "L"
  370.   StrCmp $0 "this is just an example. a very simple one." 0 strcaseerror
  371.   ${UnStrCase} $0 "This is just an example. A very simple one." "U"
  372.   StrCmp $0 "THIS IS JUST AN EXAMPLE. A VERY SIMPLE ONE." 0 strcaseerror
  373.   ${UnStrCase} $0 "This is just an example. A very simple one." "T"
  374.   StrCmp $0 "This Is Just An Example. A Very Simple One." 0 strcaseerror
  375.   ${UnStrCase} $0 "This is just an example. A very simple one." "<>"
  376.   StrCmp $0 "tHIS IS JUST AN EXAMPLE. a VERY SIMPLE ONE." 0 strcaseerror
  377.   ${UnStrCase} $0 "123456789!@#%^&*()-_=+[]{};:,./<>?" "S"
  378.   StrCmp $0 "123456789!@#%^&*()-_=+[]{};:,./<>?" 0 strcaseerror
  379.   ${UnStrCase} $0 "123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ!@#%^&*()abcdefghijklmnopqrstuvwxyz-_=+[]{};:,./<>?" "<>"
  380.   StrCmp $0 "123456789abcdefghijklmnopqrstuvwxyz!@#%^&*()ABCDEFGHIJKLMNOPQRSTUVWXYZ-_=+[]{};:,./<>?" 0 strcaseerror
  381.   ${UnStrCase} $0 "what about taking a shower tomorrow? it's late to do so now! try to sleep now. Good Night!" "S"
  382.   StrCmp $0 "What about taking a shower tomorrow? It's late to do so now! Try to sleep now. Good night!" 0 strcaseerror
  383.   !insertmacro StackVerificationEnd
  384.   IfErrors strcaseerror
  385.  
  386.   DetailPrint "PASSED StrCase test"
  387.   Goto +2
  388. strcaseerror:
  389.   DetailPrint "FAILED StrCase test"
  390.  
  391.   # Test clipboard function
  392.   !insertmacro StackVerificationStart
  393.   ${UnStrClb} $0 "StrFunc clipboard test" ">"
  394.   StrCmp $0 "" 0 strclberror
  395.   ${UnStrClb} $0 "StrFunc clipboard test #2" "<>"
  396.   StrCmp $0 "StrFunc clipboard test" 0 strclberror
  397.   ${UnStrClb} $0 "" "<"
  398.   StrCmp $0 "StrFunc clipboard test #2" 0 strclberror
  399.   ${UnStrClb} $0 "" ""
  400.   StrCmp $0 "" 0 strclberror
  401.   !insertmacro StackVerificationEnd
  402.   IfErrors strclberror
  403.  
  404.   DetailPrint "PASSED StrClb test"
  405.   Goto +2
  406. strclberror:
  407.   DetailPrint "FAILED StrClb test"
  408.  
  409.   # Test IO functions
  410.   !insertmacro StackVerificationStart
  411.   !macro untestio str
  412.   ${UnStrNSISToIO} $0 "${str}"
  413.   ${UnStrIOToNSIS} $0 $0
  414.   StrCmp $0 "${str}" 0 ioerror
  415.   !macroend
  416.   !insertmacro untestio "$\rtest$\n"
  417.   !insertmacro untestio "test$\n"
  418.   !insertmacro untestio "$\rtest"
  419.   !insertmacro untestio "test"
  420.   !insertmacro untestio "$\r\$\t$\n"
  421.   !insertmacro untestio "$\r \ $\t $\n $$"
  422.   !insertmacro untestio ""
  423.   !insertmacro untestio " "
  424.   !insertmacro StackVerificationEnd
  425.   IfErrors ioerror
  426.  
  427.   DetailPrint "PASSED StrNSISToIO/StrIOToNSIS test"
  428.   Goto +2
  429. ioerror:
  430.   DetailPrint "FAILED StrNSISToIO/StrIOToNSIS test"
  431.  
  432.   # Test string search functions
  433.   !insertmacro StackVerificationStart
  434.   ${UnStrLoc} $0 "This is just an example" "just" "<"
  435.   StrCmp $0 "11" 0 strlocerror
  436.   ${UnStrLoc} $0 a abc <
  437.   StrCmp $0 "" 0 strlocerror
  438.   ${UnStrLoc} $0 a abc >
  439.   StrCmp $0 "" 0 strlocerror
  440.   ${UnStrLoc} $0 abc a >
  441.   StrCmp $0 "0" 0 strlocerror
  442.   ${UnStrLoc} $0 abc b >
  443.   StrCmp $0 "1" 0 strlocerror
  444.   ${UnStrLoc} $0 abc c >
  445.   StrCmp $0 "2" 0 strlocerror
  446.   ${UnStrLoc} $0 abc a <
  447.   StrCmp $0 "2" 0 strlocerror
  448.   ${UnStrLoc} $0 abc b <
  449.   StrCmp $0 "1" 0 strlocerror
  450.   ${UnStrLoc} $0 abc c <
  451.   StrCmp $0 "0" 0 strlocerror
  452.   ${UnStrLoc} $0 abc d <
  453.   StrCmp $0 "" 0 strlocerror
  454.   !insertmacro StackVerificationEnd
  455.   IfErrors strlocerror
  456.  
  457.   DetailPrint "PASSED StrLoc test"
  458.   Goto +2
  459. strlocerror:
  460.   DetailPrint "FAILED StrLoc test"
  461.  
  462.   # Test string replacement
  463.   !insertmacro StackVerificationStart
  464.   ${UnStrRep} $0 "This is just an example" "an" "one"
  465.   StrCmp $0 "This is just one example" 0 strreperror
  466.   ${UnStrRep} $0 "test... test... 1 2 3..." "test" "testing"
  467.   StrCmp $0 "testing... testing... 1 2 3..." 0 strreperror
  468.   ${UnStrRep} $0 "" "test" "testing"
  469.   StrCmp $0 "" 0 strreperror
  470.   ${UnStrRep} $0 "test" "test" "testing"
  471.   StrCmp $0 "testing" 0 strreperror
  472.   ${UnStrRep} $0 "test" "test" ""
  473.   StrCmp $0 "" 0 strreperror
  474.   ${UnStrRep} $0 "test" "" "abc"
  475.   StrCmp $0 "test" 0 strreperror
  476.   ${UnStrRep} $0 "test" "" ""
  477.   StrCmp $0 "test" 0 strreperror
  478.   !insertmacro StackVerificationEnd
  479.   IfErrors strreperror
  480.  
  481.   DetailPrint "PASSED StrRep test"
  482.   Goto +2
  483. strreperror:
  484.   DetailPrint "FAILED StrRep test"
  485.  
  486.   # Test sorting
  487.   !insertmacro StackVerificationStart
  488.   ${UnStrSort} $0 "This is just an example" "" " just" "ple" "0" "0" "0"
  489.   StrCmp $0 "This is an exam" 0 strsorterror
  490.   ${UnStrSort} $0 "This is just an example" " " "j" " " "0" "" "0"
  491.   StrCmp $0 "just" 0 strsorterror
  492.   ${UnStrSort} $0 "This is just an example" "" "j" "" "0" "1" "0"
  493.   StrCmp $0 "This is just an example" 0 strsorterror
  494.   ${UnStrSort} $0 "This is just an example" " " "us" "" "0" "1" "0"
  495.   StrCmp $0 "just an example" 0 strsorterror
  496.   ${UnStrSort} $0 "This is just an example" "" "u" " " "0" "1" "0"
  497.   StrCmp $0 "This is just" 0 strsorterror
  498.   ${UnStrSort} $0 "This is just an example" " " "just" " " "0" "1" "0"
  499.   StrCmp $0 "just" 0 strsorterror
  500.   ${UnStrSort} $0 "This is just an example" " " "t" " " "0" "1" "0"
  501.   StrCmp $0 "This" 0 strsorterror
  502.   ${UnStrSort} $0 "This is just an example" " " "le" " " "0" "1" "0"
  503.   StrCmp $0 "example" 0 strsorterror
  504.   ${UnStrSort} $0 "This is just an example" " " "le" " " "1" "0" "0"
  505.   StrCmp $0 " examp" 0 strsorterror
  506.   ${UnStrSort} $0 "an error has occurred" " " "e" " " "0" "1" "0"
  507.   StrCmp $0 "error" 0 strsorterror
  508.   ${UnStrSort} $0 "" " " "something" " " "0" "1" "0"
  509.   StrCmp $0 "" 0 strsorterror
  510.   ${UnStrSort} $0 "This is just an example" " " "j" " " "" "" ""
  511.   StrCmp $0 " just " 0 strsorterror
  512.   ${UnStrSort} $0 "This is just an example" " " "j" " " "1" "0" "1"
  513.   StrCmp $0 " ust " 0 strsorterror
  514.   ${UnStrSort} $0 "This is just an example" "" "j" "" "0" "0" "1"
  515.   StrCmp $0 "This is ust an example" 0 strsorterror
  516.   ${UnStrSort} $0 "This is just an example" " " "us" "" "1" "0" "0"
  517.   StrCmp $0 " jt an example" 0 strsorterror
  518.   ${UnStrSort} $0 "This is just an example" "" "u" " " "0" "0" "1"
  519.   StrCmp $0 "This is jst " 0 strsorterror
  520.   ${UnStrSort} $0 "This is just an example" " " "just" " " "1" "0" "1"
  521.   StrCmp $0 "  " 0 strsorterror
  522.   ${UnStrSort} $0 "an error has occurred" " " "e" "h" "1" "0" "0"
  523.   StrCmp $0 " rror " 0 strsorterror
  524.   ${UnStrSort} $0 "" " " "something" " " "1" "0" "1"
  525.   StrCmp $0 "" 0 strsorterror
  526.   !insertmacro StackVerificationEnd
  527.   IfErrors strsorterror
  528.  
  529.   DetailPrint "PASSED StrSort test"
  530.   Goto +2
  531. strsorterror:
  532.   DetailPrint "FAILED StrSort test"
  533.  
  534.   !insertmacro StackVerificationStart
  535.   ${UnStrStr} $0 "abcefghijklmnopqrstuvwxyz" "g"
  536.   StrCmp $0 "ghijklmnopqrstuvwxyz" 0 strstrerror
  537.   ${UnStrStr} $0 "abcefghijklmnopqrstuvwxyz" "ga"
  538.   StrCmp $0 "" 0 strstrerror
  539.   ${UnStrStr} $0 "abcefghijklmnopqrstuvwxyz" ""
  540.   StrCmp $0 "abcefghijklmnopqrstuvwxyz" 0 strstrerror
  541.   ${UnStrStr} $0 "a" "abcefghijklmnopqrstuvwxyz"
  542.   StrCmp $0 "" 0 strstrerror
  543.   !insertmacro StackVerificationEnd
  544.   IfErrors strstrerror
  545.  
  546.   DetailPrint "PASSED StrStr test"
  547.   Goto +2
  548. strstrerror:
  549.   DetailPrint "FAILED StrStr test"
  550.  
  551.   !insertmacro StackVerificationStart
  552.   ${UnStrStrAdv} $0 "abcabcabc" "a" ">" ">" "1" "0" "0"
  553.   StrCmp $0 "abcabcabc" 0 strstradverror
  554.   ${UnStrStrAdv} $0 "abcabcabc" "a" ">" ">" "1" "1" "0"
  555.   StrCmp $0 "abcabc" 0 strstradverror
  556.   ${UnStrStrAdv} $0 "abcabcabc" "a" ">" ">" "1" "2" "0"
  557.   StrCmp $0 "abc" 0 strstradverror
  558.   ${UnStrStrAdv} $0 "abcabcabc" "a" ">" ">" "1" "3" "0"
  559.   StrCmp $0 "" 0 strstradverror
  560.   ${UnStrStrAdv} $0 "abcabcabc" "abc" ">" "<" "1" "1" "0"
  561.   StrCmp $0 "abcabc" 0 strstradverror
  562.   ${UnStrStrAdv} $0 "abcabcabc" "abc" ">" "<" "0" "1" "0"
  563.   StrCmp $0 "abc" 0 strstradverror
  564.   ${UnStrStrAdv} $0 "abcabcabc" "abc" "<" "<" "1" "0" "0"
  565.   StrCmp $0 "abcabcabc" 0 strstradverror
  566.   ${UnStrStrAdv} $0 "abcabcabc" "abc" "<" "<" "0" "0" "0"
  567.   StrCmp $0 "abcabc" 0 strstradverror
  568.   ${UnStrStrAdv} $0 "abcabcabc" "abc" "<" ">" "0" "0" "0"
  569.   StrCmp $0 "" 0 strstradverror
  570.   ${UnStrStrAdv} $0 "abcabcabc" "abc" "<" ">" "0" "1" "0"
  571.   StrCmp $0 "abc" 0 strstradverror
  572.   ${UnStrStrAdv} $0 "ABCabcabc" "a" ">" ">" "1" "0" "1"
  573.   StrCmp $0 "abcabc" 0 strstradverror
  574.   ${UnStrStrAdv} $0 "ABCabcabc" "a" ">" ">" "1" "1" "1"
  575.   StrCmp $0 "abc" 0 strstradverror
  576.   ${UnStrStrAdv} $0 "ABCabcabc" "a" ">" ">" "1" "2" "1"
  577.   StrCmp $0 "" 0 strstradverror
  578.   ${UnStrStrAdv} $0 "ABCabcabc" "a" ">" ">" "1" "3" "1"
  579.   StrCmp $0 "" 0 strstradverror
  580.   ${UnStrStrAdv} $0 "ABCabcabc" "abc" ">" "<" "1" "1" "1"
  581.   StrCmp $0 "ABCabcabc" 0 strstradverror
  582.   ${UnStrStrAdv} $0 "ABCabcabc" "abc" ">" "<" "0" "1" "1"
  583.   StrCmp $0 "ABCabc" 0 strstradverror
  584.   ${UnStrStrAdv} $0 "ABCabcabc" "abc" "<" "<" "1" "0" "1"
  585.   StrCmp $0 "ABCabcabc" 0 strstradverror
  586.   ${UnStrStrAdv} $0 "ABCabcabc" "abc" "<" "<" "0" "0" "1"
  587.   StrCmp $0 "ABCabc" 0 strstradverror
  588.   ${UnStrStrAdv} $0 "ABCabcabc" "abc" "<" ">" "0" "0" "1"
  589.   StrCmp $0 "" 0 strstradverror
  590.   ${UnStrStrAdv} $0 "ABCabcabc" "abc" "<" ">" "0" "1" "1"
  591.   StrCmp $0 "abc" 0 strstradverror
  592.   !insertmacro StackVerificationEnd
  593.   IfErrors strstradverror
  594.  
  595.   DetailPrint "PASSED StrStrAdv test"
  596.   Goto +2
  597. strstradverror:
  598.   DetailPrint "FAILED StrStrAdv test"
  599.  
  600.   # Test tokenizer
  601.   !insertmacro StackVerificationStart
  602.   ${UnStrTok} $0 "This is, or is not, just an example" " ," "4" "1"
  603.   StrCmp $0 "not" 0 strtokerror
  604.   ${UnStrTok} $0 "This is, or is not, just an example" " ," "4" "0"
  605.   StrCmp $0 "is" 0 strtokerror
  606.   ${UnStrTok} $0 "This is, or is not, just an example" " ," "152" "0"
  607.   StrCmp $0 "" 0 strtokerror
  608.   ${UnStrTok} $0 "This is, or is not, just an example" " ," "" "0"
  609.   StrCmp $0 "example" 0 strtokerror
  610.   ${UnStrTok} $0 "This is, or is not, just an example" " ," "L" "0"
  611.   StrCmp $0 "example" 0 strtokerror
  612.   ${UnStrTok} $0 "This is, or is not, just an example" " ," "0" "0"
  613.   StrCmp $0 "This" 0 strtokerror
  614.   !insertmacro StackVerificationEnd
  615.   IfErrors strtokerror
  616.  
  617.   DetailPrint "PASSED StrTok test"
  618.   Goto +2
  619. strtokerror:
  620.   DetailPrint "FAILED StrTok test"
  621.  
  622.   # Test trim new lines
  623.   !insertmacro StackVerificationStart
  624.   ${UnStrTrimNewLines} $0 "$\r$\ntest$\r$\ntest$\r$\n"
  625.   StrCmp $0 "$\r$\ntest$\r$\ntest" 0 strtrimnewlineserror
  626.   !insertmacro StackVerificationEnd
  627.   IfErrors strtrimnewlineserror
  628.  
  629.   DetailPrint "PASSED StrTrimNewLines test"
  630.   Goto +2
  631. strtrimnewlineserror:
  632.   DetailPrint "FAILED StrTrimNewLines test"
  633.  
  634. SectionEnd
  635.